package inet.app.controller.parser;

import inet.app.model.object.Slave;

import java.util.ArrayList;
import org.json.JSONObject;
public class Parser_Slave_Resp {
	private String NAME="SLAVE_RESP";
	private ArrayList<Slave> list = new ArrayList<Slave>();
	public Parser_Slave_Resp() {
		
	}
	public Slave parser(String json){
		try {
			String data[] = json.split("\\|");
			String name = data[0];
			System.out.println("NAME" + name);
			String status = data[1];
			System.out.println("Status" + status);
			if(status.equals("0") && name.equals(NAME)){
				String ip, appid;
				int port;
					ip = data[2];
					port =Integer.parseInt(data[3]);
					appid = data[4];
					Slave slave = new Slave(ip, port,appid);
				return slave;
			}else {
				return null;
			}
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		}
	}

}
